open(FH,"</Users/yaping/Documents/workspace/gatk_read/Sting/resources/dbsnp_130_hg18.sort.rod");
my @in=<FH>;
chomp(@in);
close(FH);
my @out;
foreach my $line(@in){
	my @splitin=split "\t",$line;
	my $chr=$splitin[1];
	my $pos=$splitin[3];
	my $allele_freq=0;
	my $validated, $indel;
	my $key1="A";
	my $key2="C";
	my $key3="T";
	my $key4="G";
	my %freq = (
		$key1 => 0,
		$key2 => 0,
		$key3 => 0,
		$key4 => 0,
	);
	my $snp_id=$splitin[4];
	my $base1, $base2;

	if($splitin[11] eq "in-del" || $splitin[11] eq "insertion" || $splitin[11] eq "deletion"){
		$indel=1;
	}
	else{
		$indel=0;
	}
	if($splitin[12] eq "unknown"){
		$validated=0;
	}
	else{
		$validated=1;
	}
	if($splitin[9] =~ /(\S)\/(\S)/ ){
		$base1=$1;
		$base2=$2;
	}
	if(exists $freq{$base1} ){
		$freq{$base1}=0.5;
	}
	if(exists $freq{$base2} ){
		$freq{$base2}=0.5;
	}
	push(@out,"$chr\t$pos\t$allele_freq\t$validated\t$indel\t$freq{$key1}\t$freq{$key2}\t$freq{$key3}\t$freq{$key4}\t$snp_id\n");
}
open(OUT, ">/Users/yaping/Documents/workspace/gatk_read/Sting/resources/dbsnp_130_hg18.sort.soapsnp.txt");
print OUT @out;
close(OUT);
